import requests
from IPython.display import display, Image
import json
import time
next = ''
posts = []
for i in range(2):
result = json.loads(
requests.get('https://api.reddit.com/r/pics',
params={"after": next},
headers={'User-Agent': 'Mozilla/5 Data Science Intro'}).text)
next = result["data"]["after"]
posts = posts + result["data"]["children"]
posts = [post["data"] for post in posts if post["data"]["url"].endswith("jpg")]
print(len(posts))
for post in posts:
display(post["url"])
display(Image(post["url"]))
print(post["title"])
print()
time.sleep(0.5)